/*
 * modelConnector.h
 *
 *  Created on: Nov 26, 2012
 *      Author: Michiel Hegemans
 */

#ifndef MODELCONNECTOR_H_
#define MODELCONNECTOR_H_

#include <ros/ros.h>
#include <sensor_msgs/JointState.h>

#include "model_values.h"
#include "topic/topic.h"
#include "joint_names.h"

class ModelConnector {
	private:
	protected:
		ros::NodeHandle nh_;
		ros::Subscriber emotion_handler_sub_;
		ros::Publisher joint_pub_;
		sensor_msgs::JointState joint_state_;

		bool _done;

		inline void publish() {
			joint_pub_.publish(joint_state_);
		}
	public:
		ModelConnector() : nh_("") {
			_done 			= true;
			joint_pub_	= nh_.advertise<sensor_msgs::JointState>(Topic::JOINTSTATES, 1);
		}
		~ModelConnector() {
			nh_.shutdown();
		}
		void init();
		void spin();
		void prepState();
		bool isInPosition() { return _done; }
		void setInPosition(bool state) { _done = state; }
};

#endif /* MODELCONNECTOR_H_ */
